package com.avic.map.common.convertor;


import com.avic.map.common.model.enums.MapDataStatusEnums;
import com.avic.map.controller.info.MapSoldierResourceListInfo;
import com.avic.map.dal.model.SingleSoldierResource;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 地图船舶资源对象转换器
 *
 * @author huangsheng
 */
public class MapSoldierResourceConvertor {


    public static List<MapSoldierResourceListInfo> singleSoldierResourceListToMapSoldierResourceListInfoList(List<SingleSoldierResource> singleSoldierResources) {
        if (null != singleSoldierResources && singleSoldierResources.size() > 0) {
            List<MapSoldierResourceListInfo> mapCarResourceListInfos = new ArrayList<>(singleSoldierResources.size());
            singleSoldierResources.forEach(singleSoldierResource -> {
                MapSoldierResourceListInfo mapSoldierResourceListInfo = new MapSoldierResourceListInfo();
                mapSoldierResourceListInfo.setSoldierNumber(singleSoldierResource.getPersonnelNumber());
                mapSoldierResourceListInfo.setSoldierState(singleSoldierResource.getSoldierState());
                mapSoldierResourceListInfo.setEquipmentType(singleSoldierResource.getEquipmentType());

                MapDataStatusEnums mapDataStatusEnums = MapDataStatusEnums.getMapDataStatusEnumsByType(singleSoldierResource.getSoldierState());
                mapSoldierResourceListInfo.setSoldierStateDescribe(null != mapDataStatusEnums ? mapDataStatusEnums.getMapStateValue() : StringUtils.EMPTY);

                mapSoldierResourceListInfo.setCallSign(singleSoldierResource.getCallSign());
                mapSoldierResourceListInfo.setPersonnelCompany(singleSoldierResource.getPersonnelCompany());
                mapCarResourceListInfos.add(mapSoldierResourceListInfo);
            });
            return mapCarResourceListInfos;
        }
        return new ArrayList<>();
    }
}
